/**
 * Copyright (c) 2011 eelpo.com
 * All rights reserved.
 */
package com.eelpo.cmmp.uac.dao.vo;

import java.io.Serializable;

import com.eelpo.cmmp.uac.dao.vo.enumed.Status;
import com.eelpo.common.util.BlankUtils;

/**
 * <pre>
 * 
 * 权限值对象
 * 
 * </pre>
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public class Permission implements Serializable {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -1442402127272949704L;
	/**
	 * 权限Id
	 */
	private String id;

	/**
	 * 权限代码
	 */
	private String code;

	/**
	 * 权限状态
	 */
	private Status status;

	/**
	 * 权限操作的实体
	 */
	private Entity entity;

	/**
	 * 权限所做的操作
	 */
	private Action action;

	public Permission() {

	}

	public Permission(String id) {
		this.id = id;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Entity getEntity() {
		return entity;
	}

	public void setEntity(Entity entity) {
		this.entity = entity;
	}

	public Action getAction() {
		return action;
	}

	public void setAction(Action action) {
		this.action = action;
	}

	@Override
	public boolean equals(Object obj) {
		if (BlankUtils.isBlank(obj) || !(obj instanceof Permission))
			return false;

		if (this == obj)
			return true;

		Permission permission = (Permission) obj;

		if (BlankUtils.isBlank(this.id) || BlankUtils.isBlank(permission.getId())) {
			return false;
		}

		return this.id.equals(permission.getId());
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public String toString() {
		return "TPermission [code=" + code + "]";
	}
}
